package com.example.service.impl;

import com.example.dao.TypeDao;
import com.example.dao.impl.TypeDaoImpl;
import com.example.model.Type;
import com.example.service.TypeService;

import java.util.List;

public class TypeServiceImpl implements TypeService {

    @Override
    public List<Type> getAll() {
        TypeDao typeDao = new TypeDaoImpl();
        return typeDao.queryAll();
    }

    @Override
    public boolean save(String name) {
        TypeDao typeDao = new TypeDaoImpl();
        int i = typeDao.insert(name);
        return i == 1 ? true : false;
    }

    @Override
    public boolean delete(String id) {
        TypeDao typeDao = new TypeDaoImpl();
        int _id = Integer.parseInt(id);
        int i = typeDao.removeById(_id);
        return i == 1 ? true : false;
    }
}
